package com.service.Impl;

import com.dao.AreaDao;
import com.dao.ManagerDao;
import com.dao.OperatorDao;
import com.dao.PoorDao;
import com.pojo.Area;
import com.pojo.Manager;
import com.pojo.Operator;
import com.pojo.Poor;
import com.service.ManageService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@MapperScan("com.dao")
public class ManagerServiceImpl implements ManageService {
       //管理员管理贫困种类表，地区表，操作员信息表
//       注入要用到的dao对象
       @Autowired
       AreaDao areaDao;
       @Autowired
       OperatorDao operatorDao;
       @Autowired
       PoorDao poorDao;

       @Autowired
       ManagerDao managerDao;

       @Override
       public List<Area> selectAllArea() {
              return areaDao.selectList(null);
       }

       @Override
       public Area selectById(Integer id) {
              return areaDao.selectById(id);
       }

       @Override
       public boolean updateArea(Area area) {
              return areaDao.updateById(area)>0;
       }

       @Override
       public boolean deleteArea(Integer id) {
              return areaDao.deleteById(id)>0;
       }

       @Override
       public boolean addArea(Area area) {
              return areaDao.insert(area)>0;
       }

       @Override
       public boolean addOperator(Operator operator) {
              return operatorDao.insert(operator)>0;
       }

       @Override
       public Operator selectOpById(Integer id) {
              return operatorDao.selectById(id);
       }

       @Override
       public boolean updateOperator(Operator operator) {
              return operatorDao.updateById(operator)>0;
       }

       @Override
       public boolean deleteOperator(Integer id) {
              return operatorDao.deleteById(id)>0;
       }

       @Override
       public List<Operator> selectAllOperator(Integer id) {
              return operatorDao.searchAllByAreaIdIn(id);
       }


       @Override
       public List<Poor> selectAllPoor() {
              return poorDao.selectList(null);
       }


       @Override
       public boolean deletePoor(Integer id) {
              return poorDao.deleteById(id)>0;
       }

       @Override
       public boolean updatePoor(Poor poor) {
              return poorDao.updateById(poor)>0;
       }

       @Override
       public boolean addPoor(Poor poor) {
              return poorDao.insert(poor)>0;
       }

       @Override
       public boolean login(Manager manager) {
              return managerDao.login(manager)!=null;
       }


}

